<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c"  uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>index</title>
 
<!-- Required Stylesheets -->
<link href="<%=request.getContextPath()%>/css/bootstrap/bootstrap.min.css" rel="stylesheet">
<link href="<%=request.getContextPath()%>/css/icheck/blue.css">
<link rel="stylesheet" href="<%=request.getContextPath()%>/css/fileupload.css"/>
<!-- Required Javascript -->
<script src="<%=request.getContextPath()%>/js/jquery-3.1.1.min.js"></script>
<script src="<%=request.getContextPath()%>/js/bootstrap.js" type="text/javascript"></script>
<script src="<%=request.getContextPath()%>/js/bootstrap/bootstrap-treeview.min.js"></script>
<script src="<%=request.getContextPath()%>/js/ajaxfileupload.js"></script>
 <style>
       #tree{
          width:300px;
          margin:20px auto;
       }
    </style>
  </head>
  
  <body>
    <c:if test="${params=='productAttrMappingMng' }">
    <div id="tree" style="display:inline-block;"></div>
    <div style="width:300px;display:inline-block;float: left">
	    
	    	<input id="detailsDocumentUpload" type="file" name="file" onchange="ajaxFileUpload('productAttr/ProductAttrMapping_excelImportMapping')" /> 
	     	<input type="button" class="btn btn-default" value="属性映射上传" onclick="javascript:detailsDocumentUpload.click()" />
	     	<input type="button" class="btn btn-default" value="映射模版下载" onclick="location.href='<%=request.getContextPath()%>/productAttr/ProductAttrMapping_downloadTemple'" />
	     	<input id="attrCheckUpload" class="detailsDocumentUpload" type="file" name="file" onchange="ajaxFileUpload('<%=request.getContextPath()%>/productMain/Product_excelProductAttrCheck','attrCheckUpload')" /> 
	     	<input type="button" class="btn btn-default" value="属性校验上传" onclick="javascript:attrCheckUpload.click()" />
	    	<input type="button" class="btn btn-default" value="属性校验模版下载" onclick="location.href='<%=request.getContextPath()%>/productAttr/ProductAttr_downloadCheckTemple'" />
    </div>
    <div style="display:inline-block;float: left"></div>
    </c:if>
    <div id="tree" ></div>
    <script type="text/javascript">
   $(function(){
    	$.ajax({
    		url:"<%=request.getContextPath()%>/category/category_getCategoryTree?id=1",
    		dataType:"text",
    		success:function(data){
    			var tree = '['+data+']';
    			//alert(tree);
    			$('#tree').treeview({data: tree});//,enableLinks:true
    			$('#tree').treeview('expandAll', { levels: 4, silent: true });
    			$('#tree').on('nodeSelected', function(event, node) {
    				
    				//tag数组第一位是id，第二位是level
    				if(node.tags[1]==4){   //叶节点跳转页面
    					var id=node.tags[0];
    				    var name=node.text;
    				    if('${param.params}'=='productAttrMng'||'${param.params}'=='productAttrMappingMng'){//跳转到属性组列表
    				    	location.href='<%=request.getContextPath()%>/productAttrGroup/ProductAttrGroup_toShowChooseGroupFrame?t1.categoryId='+id+'&t1.category.name='+name+'&params=${params}';
    				    }
    				    if('${param.params}'=='productSeriesList'){//跳转到系列列表
    				    	location.href='<%=request.getContextPath()%>/productSeries/ProductSeries_listByPage?t1.category.id='+id+'&t1.category.name='+name;
    				    }
    				    if('${param.params}'=='toAddProduct'){//跳转到product
    				    	location.href='<%=request.getContextPath()%>/productMain/Product_toAdd?t.category.id='+id+'&t.category.name='+name;
    				    }
    				    if('${param.params}'=='toAddAttrRule'){//跳转到product
    				    	location.href='<%=request.getContextPath()%>/attrRule/AttrRule_toAdd?t.category.id='+id+'&t.category.name='+name;
    				    }
    				    if('${param.params}'=='toAddNameProductRule'){//跳转到product
    				    	location.href='<%=request.getContextPath()%>/nameProductRule/NameProductRule_toAdd?t.category.id='+id+'&t.category.name='+name;
    				    }
    				}else{
    				
    				}

    			});
    		}
    	});
    });

    </script>
  
  </body>
  
</html>
